package com.hlt.meta.aspect;

import com.hlt.meta.common.LogHelper;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.stereotype.Component;

@Component
@Aspect
public class ControllerAop {
    @Pointcut("execution(* com.hlt.meta.controller.*.*(..))")
    public void executeService() {
        LogHelper.Info("executeService");
    }
    @Before("executeService()")
    public void doBefore(JoinPoint joinPoint) throws Throwable {
        LogHelper.Info("doBefore:"+joinPoint.toString());
    }
    @AfterReturning(returning = "ret", pointcut = "executeService()")
    public void doAfterReturning(Object ret) throws Throwable {
        // 处理完请求，返回内容
        LogHelper.Info("doAfterReturning:"+ret.toString());
    }
    //后置异常通知
    @AfterThrowing("executeService()")
    public void afterThrows(JoinPoint jp){
        LogHelper.Info("afterThrows:"+jp.toString());
    }

    //后置最终通知,final增强，不管是抛出异常或者正常退出都会执行
    @After("executeService()")
    public void doAfter(JoinPoint jp){
        LogHelper.Info("doAfter:"+jp.toString());
    }

}
